package com.tr1701_demo.controller;


import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tr1701_demo.moder.dao.AccountDao;
import com.tr1701_demo.moder.entitys.AccountGoodsVo;

/**
 * Servlet implementation class AccountServlet
 */
@WebServlet("/AccountServlet")
public class AccountServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AccountServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		List<AccountGoodsVo> list=new AccountDao().getAccounts("'20H3A004CD','20H7A00HCD'");
		
		if(list.size()>0){
			request.setAttribute("buylist", list);
			BigDecimal a=new BigDecimal(0);
			for(AccountGoodsVo jz:list){
				a=jz.getGprice().add(a);
			}
			request.setAttribute("buylis1t", a);
			
		}
		request.getRequestDispatcher("jsps/jiesuan.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
